package com.zhoukx.netty.inboundhandlerAndOutboundhandler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;

import java.util.List;

public class MyByteToLongDecodec2  extends ReplayingDecoder<Void> {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        System.out.println("MyByteTolongDecoder decode 被调用");
        // 在ReplayingDecoder 中不需要判断数据是否足够读取,内部会判断
//        if (in.readableBytes() >= 8) {
//            out.add(in.readLong());
//        }
        out.add(in.readLong());
    }
}
